#pragma once

#include <stdio.h>

enum
{
   STBI_default = 0, // only used for req_comp

   STBI_grey       = 1,
   STBI_grey_alpha = 2,
   STBI_rgb        = 3,
   STBI_rgb_alpha  = 4,
};

typedef unsigned char stbi_uc;

#ifdef __cplusplus
extern "C" {
#endif

// PRIMARY API - works on images of any type

// load image by filename, open file, or memory buffer
extern stbi_uc *stbi_load            (char *filename,           int *x, int *y, int *comp, int req_comp);
extern stbi_uc *stbi_load_from_file  (FILE *f,                  int *x, int *y, int *comp, int req_comp);
extern stbi_uc *stbi_load_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp);
// for stbi_load_from_file, file pointer is left pointing immediately after image

// get a VERY brief reason for failure
extern char    *stbi_failure_reason  (void);

// free the loaded image -- this is just free()
extern void     stbi_image_free      (stbi_uc *retval_from_stbi_load);

// get image dimensions & components without fully decoding
extern int      stbi_info            (char *filename,           int *x, int *y, int *comp);
extern int      stbi_info_from_file  (char *filename,           int *x, int *y, int *comp);
extern int      stbi_info_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp);

#ifndef STBI_NO_WRITE
// write a .BMP file given tightly packed 'comp' tightly packed channels (not padded, or bmp-padded)
// returns TRUE on success, FALSE if couldn't open file, error writing file
extern int      stbi_write_bmp       (char *filename,           int x, int y, int comp, void *data);
#endif

// ZLIB client - used by PNG, available for other purposes

extern char *stbi_zlib_decode_malloc_guesssize(int initial_size, int *outlen);
extern char *stbi_zlib_decode_malloc(char *buffer, int len, int *outlen);
extern int   stbi_zlib_decode_buffer(char *obuffer, int olen, char *ibuffer, int ilen);


// TYPE-SPECIFIC ACCESS

// is it a jpeg?
extern int      stbi_jpeg_test_file       (FILE *f);
extern int      stbi_jpeg_test_memory     (stbi_uc *buffer, int len);

extern stbi_uc *stbi_jpeg_load            (char *filename,           int *x, int *y, int *comp, int req_comp);
extern stbi_uc *stbi_jpeg_load_from_file  (FILE *f,                  int *x, int *y, int *comp, int req_comp);
extern stbi_uc *stbi_jpeg_load_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp);
extern int      stbi_jpeg_info            (char *filename,           int *x, int *y, int *comp);
extern int      stbi_jpeg_info_from_file  (char *filename,           int *x, int *y, int *comp);
extern int      stbi_jpeg_info_from_memory(stbi_uc *buffer, int len, int *x, int *y, int *comp);

// is it a png?
extern int      stbi_png_test_file        (FILE *f);
extern int      stbi_png_test_memory      (stbi_uc *buffer, int len);

extern stbi_uc *stbi_png_load             (char *filename,           int *x, int *y, int *comp, int req_comp);
extern stbi_uc *stbi_png_load_from_file   (FILE *f,                  int *x, int *y, int *comp, int req_comp);
extern stbi_uc *stbi_png_load_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp, int req_comp);
extern int      stbi_png_info             (char *filename,           int *x, int *y, int *comp);
extern int      stbi_png_info_from_file   (char *filename,           int *x, int *y, int *comp);
extern int      stbi_png_info_from_memory (stbi_uc *buffer, int len, int *x, int *y, int *comp);

#ifdef __cplusplus
}
#endif

//
//
////   end header file   /////////////////////////////////////////////////////
